package com.dhcc.service.impl;

import cn.hutool.poi.exceptions.POIException;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dhcc.entity.SysUserPosition;
import com.dhcc.mapper.InstitutionRoleDepartmentPositionMapper;
import com.dhcc.mapper.SysUserPositionMapper;
import com.dhcc.service.SysUserPositionService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SysUserPositionServiceImpl extends ServiceImpl<SysUserPositionMapper, SysUserPosition> implements SysUserPositionService {
    @Resource
    private SysUserPositionMapper sysPositionMapper;
    @Resource
    private InstitutionRoleDepartmentPositionMapper institutionRoleDepartmentPositionMapper;
    @Override
    public SysUserPosition getPositionName(String userPositionId) {

        return sysPositionMapper.getPositionName(userPositionId);
    }

    @Override
    public List<String> getPositionNameList(String institutionId, String institutionRoleId, String departmentId) {
        List<String> positionIds= institutionRoleDepartmentPositionMapper.getPositionIds(institutionId,institutionRoleId,departmentId);
        List<String> posotionNameList=new ArrayList<>();
        for (String positionId : positionIds) {
            SysUserPosition position = sysPositionMapper.getPositionName(positionId);
            posotionNameList.add(position.getPositionName());
        }
        return posotionNameList;
    }

    @Override
    public Integer addPosition(SysUserPosition sysUserPosition) {
        return sysPositionMapper.addPosition(sysUserPosition);
    }

    @Override
    public Integer deletePosition(String positionId) {
        return sysPositionMapper.deletePosition(positionId);
    }

    @Override
    public Integer updatePosition(SysUserPosition sysUserPosition) {
        return sysPositionMapper.updatePosition(sysUserPosition);
    }


}
